import os
import json


class PluginManager(object):
    pluginList = []

    def __init__(self):
        super().__init__()

    def __plugin_parser(self, jsonFile):
        jsonData = json.load(open(jsonFile))
        print(jsonData["name"])

    def load_plugins(self, path):
        """
        加载插件
        :path: 插件地址
        """
        # 获取插件文件夹
        dirs = [os.path.join(path, i) for i in os.listdir(
            path) if os.path.isdir(os.path.join(path, i))]
        # 分析插件
        for dir in dirs:
            jsonFile = os.path.join(dir, "plugin.json")
            if os.path.isfile(jsonFile):
                self.plugin_parser(jsonFile)
        # plugin_load(plugin_name:str, sep=":"):
        # m, _, c = plugin_name.partition(sep)
        # mod = importlib.import_module(m)
        # cls = getattr(mod, c)
        # return cls()


class Plugin(object):
    name = ""
    command = ""
    help = ""
    func = []
    